package com.lovo.csc.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.lovo.csc.bean.OrderInfoBean;
import com.lovo.csc.mapper.IOrderInfoMapper;
import com.lovo.csc.service.IOrderInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
@Transactional
public class OrderInfoServiceImpl implements IOrderInfoService {
    @Autowired
    private IOrderInfoMapper orderInfoMapper;
    /**
     * 提供给后端供应商退货的接口
     */
    @Override
    public void updateStatusTo3(String idNum) {
        QueryWrapper<OrderInfoBean> qw=new QueryWrapper<>();
        qw.eq("oi_idNum",idNum);
        OrderInfoBean orderInfo=orderInfoMapper.selectOne(qw);
        orderInfo.setOrderState(3);
        orderInfoMapper.updateById(orderInfo);

    }

    /**
     * 页面展示待退款批次记录
     * @param pageNO
     * @return
     */
    @Override
    public IPage<OrderInfoBean> findAll3(int pageNO) {
        QueryWrapper<OrderInfoBean> qw=new QueryWrapper<>();
        qw.eq("oi_orderState",3);
        return orderInfoMapper.selectPage(new Page<>(pageNO,8),qw);
    }

    /**
     * 确认退货  修改状态为4
     * @param idNum
     */
    @Override
    public void updateStatusTo4(String idNum) {
        QueryWrapper<OrderInfoBean> qw=new QueryWrapper<>();
        qw.eq("oi_idNum",idNum);
        OrderInfoBean orderInfo=orderInfoMapper.selectOne(qw);
        orderInfo.setOrderState(4);
        orderInfoMapper.updateById(orderInfo);
    }
}
